home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 August: Tool Chest / Dev.CD Aug 00 TC Disk 2.toast / pc / sample code / interapplication comm / moreosl / moretoolbox / moretoolbox.cp next >
Encoding:
Text File  |  2000-06-23  |  2.6 KB  |  113 lines

  1. /*
  2.     File:        MoreToolbox.cp
  3.  
  4.     Contains:    
  5.  
  6.     Written by:    Pete Gontier
  7.  
  8.     Copyright:    Copyright (c) 1998 Apple Computer, Inc., All Rights Reserved.
  9.  
  10.                 You may incorporate this Apple sample source code into your program(s) without
  11.                 restriction. This Apple sample source code has been provided "AS IS" and the
  12.                 responsibility for its operation is yours. You are not permitted to redistribute
  13.                 this Apple sample source code as "Apple sample source code" after having made
  14.                 changes. If you're going to re-distribute the source, we require that you make
  15.                 it clear in the source that the code was descended from Apple sample source
  16.                 code, but that you've made changes.
  17.  
  18.     Change History (most recent first):
  19.  
  20.          <5>      2/9/99    PCG     lose QDGlobals and ShowWatchCursor
  21.          <4>     1/29/99    PCG     new Carbon
  22.          <3>     1/22/99    PCG     TARGET_CARBON
  23.          <2>    11/11/98    PCG     fix header
  24.          <1>    11/10/98    PCG     first big re-org at behest of Quinn
  25.  
  26.     Old Change History (most recent first):
  27.  
  28.          <3>    10/23/98    PCG     add HavePowerManager
  29.          <2>     7/24/98    PCG        eliminate dependency on 'qd'
  30.          <1>     6/16/98    PCG     initial checkin
  31. */
  32.  
  33. #include "MoreToolbox.h"
  34. #include "MoreQuickDraw.h"
  35. #include "MoreAppearance.h"
  36.  
  37. #include <MacMemory.h>
  38. #include <Fonts.h>
  39. #include <Dialogs.h>
  40. #include <Sound.h>
  41. #include <Gestalt.h>
  42. #include <Power.h>
  43.  
  44. static long        gSystemVersion;
  45. static Boolean    gHavePowerManager;
  46.  
  47. pascal long GetSystemVersion (void)
  48. {
  49.     //
  50.     //    Simply returns our cached variable. See InitMac
  51.     //    for how this variable is initialized.
  52.     //
  53.  
  54.     return gSystemVersion;
  55. }
  56.  
  57. pascal Boolean HaveAppleEvents (void)
  58. {
  59.     return 0x0700 <= GetSystemVersion ( ); // cheating
  60. }
  61.  
  62. pascal OSStatus InitMac (void)
  63. {
  64.     OSStatus err = noErr;
  65.  
  66.     if (!(err = Gestalt (gestaltSystemVersion, &gSystemVersion)))
  67.     {
  68.         long powerMgrResponse;
  69.         err = Gestalt (gestaltPowerMgrAttr,&powerMgrResponse);
  70.  
  71.         if (err == gestaltUndefSelectorErr)
  72.             err = noErr;
  73.         else if (!err)
  74.         {
  75.             gHavePowerManager = (powerMgrResponse & (1L << gestaltPMgrExists)) ? true : false;
  76.  
  77. #if !TARGET_CARBON
  78.  
  79.             MaxApplZone ( );
  80.             (void) MoreAssert (MemError ( ) == noErr);
  81.  
  82.             InitGraf (&(qd.thePort));
  83.             InitFonts ( );
  84.             InitWindows ( );
  85.             InitMenus ( );
  86.             TEInit ( );
  87.             InitDialogs (nil);
  88.  
  89. #endif
  90.  
  91.             if (!(err = InitMoreQuickDraw ( )))
  92.             {
  93.                 if (!(err = InitMoreAppearance ( )))
  94.                 {
  95.                     err = ShowWatchCursor ( );
  96.                 }
  97.             }
  98.         }
  99.     }
  100.  
  101.     return err;
  102. }
  103.  
  104. pascal void Beep (void)
  105. {
  106.     SysBeep (10);
  107. }
  108.  
  109. pascal Boolean HavePowerManager (void)
  110. {
  111.     return gHavePowerManager;
  112. }
  113.